#include <iostream>
#include <sys/types.h>
#include <unistd.h>
#include <signal.h>
using namespace std;

void handler(int signo)
{
    cout << "handler :" << signo << endl; //打印信号
    //exit(100);
}

int main()
{
    cout << "getpid :" << getpid() << endl;
    cout << "自定义行为" << endl;
    signal(2, handler); //自定义
    sleep(10);
    cout << "恢复默认行为" << endl;
    signal(2, SIG_DFL); //恢复默认处理动作

    sleep(10);
    cout << "getpid :" << getpid() << endl;
    cout << "getpid :" << getpid() << endl;
    cout << "getpid :" << getpid() << endl;
    cout << "getpid :" << getpid() << endl;

    return 0;
}